package com.flca.frw.config;

import java.io.File;
import java.io.FileFilter;

/**
 *  Use this fileter if you want to filter for a given filename with wildcard(s) for example":
 *  FilePatternFilter fpf = new FilePatternFilter("*.jar:*.zip");
 * @author nly36776
 *
 */
public class FilePatternFilter implements FileFilter {

	FilePatternMatcher pattern;

	public FilePatternFilter(String wildcards) {
		super();
		this.pattern = new FilePatternMatcher(wildcards);
	}

	public FilePatternFilter(FilePatternMatcher pattern) {
		super();
		this.pattern = pattern;
	}

	@Override
	public boolean accept(File pathname) {
		if (pathname.isDirectory()) {
			return true;
		} else {
			boolean b = pattern.matches(pathname.getPath());
			if (b) {
				System.out.println(pathname);
			}
			return b;
		}
	}
	
}
